//
//  ViewController.m
//  ZSDependencyCategory-master
//
//  Created by safiri on 2018/8/10.
//  Copyright © 2018年 safiri. All rights reserved.
//

#import "ViewController.h"
#import "ZSDependencyCategory.h"

@interface ViewController ()

@property (nonatomic, strong) UIButton *animationButton;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setImage:[UIImage imageNamed:@"hb_draw"] forState:UIControlStateNormal];
    [button setFrame:CGRectMake(100, 100, 64, 80)];
    [button addTarget:self action:@selector(buttonclick) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
    self.animationButton = button;
    
    
}

- (void)buttonclick {
    
    //[_animationButton scaleSelf];
    [_animationButton rotationY3DSelf];
}
- (IBAction)progressHUDTest:(id)sender {
    __block CGFloat progress = 0;
    NSProgress *progressob = [NSProgress progressWithTotalUnitCount:100];
    dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
    dispatch_source_t timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
    dispatch_source_set_timer(timer, DISPATCH_TIME_NOW, 0.1 * NSEC_PER_SEC, 0 * NSEC_PER_SEC);
    dispatch_source_set_event_handler(timer, ^{
        progress += 1;
        if (progress >= 100) { //倒计时结束，关闭
            dispatch_source_cancel(timer);
            dispatch_async(dispatch_get_main_queue(), ^{
                //[self hideProgressRingShapedHUDInSelfView];
                [self hideProgressHorizontalBarHUDInSelfView];
//                UIImage *image = [[UIImage imageNamed:@"Checkmark"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
//                UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
//                [self showCustomHUDAutoHideInView:self.view custom:imageView text:@"上传成功!"];
            });
        }
        dispatch_async(dispatch_get_main_queue(), ^{
           
            progressob.completedUnitCount = progress;
            //[self showProgressRingShapedHUDInSelfViewWaitText:@"loading..." progress:progressob];
            [self showProgressHorizontalBarMBHUDHUDInSelfViewWaitText:progressob.localizedDescription progress:progressob];
        });
        
    });
    dispatch_resume(timer);

}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    //[_animationButton stopScaleSelf];
    [_animationButton stopRotationY3DSelf];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
